/*
 * @Description: 
 * @Date: 2024-04-11 23:51:20
 * @LastEditTime: 2024-05-23 21:50:56
 * @FilePath: \yh_fe_db_portal\src\store\module\project.js
 */
import * as types from '../type'
import { project } from '../../service'

export default {
  state: {
  },
  mutations: {
  },
  actions: {
    // 项目管理
    [types.GET_PROJECT_LIST]: (_, payload) => {
      return project.getProjectList(payload)
    },
    [types.GET_PROJECT_BY_ID]: (_, payload) => {
      return project.getProjectById(payload)
    },
    [types.SET_PROJECT]: (_, payload) => {
      return project.setProject(payload)
    },
    [types.UPDATE_PROJECT]: (_, { id, params }) => {
      return project.updateProject({ id, params })
    },
    [types.DELETE_PROJECT]: (_, payload) => {
      return project.deleteProject(payload)
    },

    // 数据源
    [types.GET_DATA_SOURCE_LIST]: (_, payload) => {
      return project.getDataSourceList(payload)
    },
    [types.GET_DATA_SOURCE_BY_ID]: (_, payload) => {
      return project.getDataSourceById(payload)
    },
    [types.SET_DATA_SOURCE]: (_, payload) => {
      return project.setDataSource(payload)
    },
    [types.UPDATE_DATA_SOURCE]: (_, { id, params }) => {
      return project.updateDataSource({ id, params })
    },
    [types.DELETE_DATA_SOURCE]: (_, payload) => {
      return project.deleteDataSource(payload)
    },
    [types.TEST_CONNECT]: (_, payload) => {
      return project.testConnect(payload)
    },
    [types.GET_CONNECTION_TYPES]: (_, payload) => {
      return project.getConnectionTypes(payload)
    },
    [types.GET_CONNECTION_LIST_BY_PROJECT]: (_, payload) => {
      return project.getConnectionListByProject(payload)
    },

    // API数据源
    [types.GET_API_TREE]: (_, payload) => {
      return project.getApiTree(payload)
    },
    [types.POST_API_CATALOG]: (_, payload) => {
      return project.postApiCatalog(payload)
    },
    [types.PUT_API_CATALOG]: (_, payload) => {
      return project.putApiCatalog(payload)
    },
    [types.DELETE_API_CATALOG]: (_, { id }) => {
      return project.deleteApiCatalog(id)
    },

    [types.GET_API_EXPORT]: (_, payload) => {
      return project.getApiExport(payload)
    },
    [types.POST_API_IMPORT]: (_, payload) => {
      return project.postApiImport(payload)
    },
    [types.POST_API_DATABASES]: (_, payload) => {
      return project.postApiDatabases(payload)
    },
    [types.GET_ALL_API_DATABASES]: (_, payload) => {
      return project.getAllApiDatabases(payload)
    },
    [types.POST_API_TABLES]: (_, payload) => {
      return project.postApiTables(payload)
    },
    [types.POST_API_COLUMNS]: (_, payload) => {
      return project.postApiColumns(payload)
    },
    [types.GET_API_DETAILS]: (_, { id }) => {
      return project.getApiDetails(id)
    },
    [types.DELETE_API]: (_, { id }) => {
      return project.deleteApi(id)
    },
    [types.POST_ADD_API]: (_, params) => {
      return project.postAddApi(params)
    },
    [types.PUT_EDIT_API]: (_, params) => {
      return project.putEditApi(params)
    },
    // API监控
    [types.POST_LOG_LIST]: (_, payload) => {
      return project.postLogList(payload)
    },
    // 资源管理
    [types.POST_ENGINE_LISTOFPAGE]: (_, payload) => {
      return project.postEngineListOfPage(payload)
    },
    [types.DELETE_ENGINE_BATCHDELETE]: (_, payload) => {
      return project.deleteEngineBatchDelete(payload)
    },
    [types.GET_ENGINE_INFO_ID]: (_, payload) => {
      return project.getEngineInfoId(payload)
    },
    [types.PUT_ENGINE_INFO_ID]: (_, payload) => {
      return project.putEngineInfoId(payload)
    },
    [types.DELETE_ENGINE_INFO_ID]: (_, payload) => {
      return project.deleteEngineInfoId(payload)
    },
    [types.POST_ADD_ENGINEINFO]: (_, payload) => {
      return project.postAddEngineInfo(payload)
    },

    // 接口令牌
    [types.GET_ACCESSTOKEN_LIST]: (_, payload) => {
      return project.getAccessTokenList(payload)
    },
    [types.SET_ACCESSTOKEN]: (_, payload) => {
      return project.setAccessToken(payload)
    },
    [types.UPDATE_ACCESSTOKEN]: (_, { id, params }) => {
      return project.updateAccessToken({ id, params })
    },
    [types.START_ACCESSTOKEN]: (_, payload) => {
      return project.startAccessToken(payload)
    },
    [types.STOP_ACCESSTOKEN]: (_, payload) => {
      return project.stopAccessToken(payload)
    },
    [types.DELETE_ACCESSTOKEN]: (_, payload) => {
      return project.deleteAccessToken(payload)
    }
  }
}
